import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/index/Index.vue'

Vue.use(VueRouter)

const routes = [{
    path: '/',
    name: 'Index',
    component: Index,
    meta: {
        pageName: '连云港石化基地封闭管理综合管控平台',
        icon: ""
    },
}, ]

const router = new VueRouter({
    // mode: 'history',
    base: process.env.BASE_URL,
    routes
})

// 路由权限控制
router.beforeEach((to, from, next) => {
    const { meta, name } = to;
    // const isLogin = Vue.$cookie.get('isLogin', Vue.$config.domain);

    // 设置页面的标题
    if (meta.pageName) {
        document.title = to.meta.pageName;
    }

    // if (name === 'login' && isLogin) {
    //     next('/');
    // }


    next();

});

export default router